/**
 * 针对S2500 测试绑核缺点 cpu影响
 * @file
 * @author yeqiang@greatwall.com.cn
 * @brief
 * @version 0.1
 * @date 2022-09-19
 *
 * @copyright Copyright (c) 2022
 *
 */
#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sched.h>
#include <errno.h>
#include <pthread.h>

void *testFunc(void *arg)
{
    double a = 123456789.123456789;
    double b = 123456789.123456789;
    while (1)
    {
        double c = a * b / (a + b);
        a = c;
    }
}

int main(int argc, char *argv[])
{
    pid_t pid = getpid();
    printf("pid=%d\n", pid);

    int cpuid = 0;
    pthread_t threads[128];

    for (int i = 0; i < 128; i++)
    {
        int err = pthread_create(&threads[i], NULL, testFunc, NULL);
        if (err != 0)
        {
            printf("线程创建失败\n");
        }
    }
    for (int i = 0; i < 128; i++)
    {
        pthread_join(threads[i], NULL);
    }

    return 0;
}